package zju.ccnt.rest.api;

import zju.ccnt.rest.domain.BusinessResource;
import zju.ccnt.rest.domain.BusinessUser;
import zju.ccnt.rest.domain.EndUser;
import zju.ccnt.rest.domain.Resource;
import zju.ccnt.oauth2.user.api.ApiUser;

/**
 * Created by zha on 14/11/12.
 */
public class ApiReplyBusinessResource {
    private ApiUser business;
    private ApiUser uploader;
    private Resource resource;
    private String id;
    private String name;
    private String description;
    //TODO 将classid转换为resource class类型
    private String classId;
    private String downloadUrl;

    public ApiReplyBusinessResource(){}

    public ApiReplyBusinessResource(BusinessResource businessResource){
        BusinessUser businessUser = businessResource.getBusinessUser();
        this.business = new ApiUser(businessUser.getId(), businessUser.getEmail(), businessUser.getName());
        this.resource = businessResource.getResource();
        this.id = businessResource.getId();
        this.name = businessResource.getName();
        this.description = businessResource.getDescription();
        this.classId = businessResource.getClassId();
        this.downloadUrl = constructDownloadUrl();
    }

    private String constructDownloadUrl(){
        if (this.resource == null) return null;
        //TODO
        return "/business_resource/"+this.id;
    }


    public String getDownloadUrl() {
        return downloadUrl;
    }

    public void setDownloadUrl(String downloadUrl) {
        this.downloadUrl = downloadUrl;
    }

    public ApiUser getBusiness() {
        return business;
    }

    public void setBusiness(ApiUser business) {
        this.business = business;
    }

    public ApiUser getUploader() {
        return uploader;
    }

    public void setUploader(ApiUser uploader) {
        this.uploader = uploader;
    }

    public Resource getResource() {
        return resource;
    }

    public void setResource(Resource resource) {
        this.resource = resource;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getClassId() {
        return classId;
    }

    public void setClassId(String classId) {
        this.classId = classId;
    }


}
